﻿myApp.controller("activity_controller", function ($scope, $post, $http, $resource, $routeParams, $restUrls, $rootScope, $location) {
    
   

    $scope.page = 0;


    $scope.list = [];
    $scope.distance = 0;
    $scope.paginating = false;
    $scope.enabled = true;

    $scope.loadList = function () {
        if (!$scope.enabled || true === $scope.paginating)
            return;

        var parameters = {
            pageNum: $scope.page++,
            pageSize: 20
        };

        $scope.paginating = true;

        $resource($restUrls["getMyActivities"] + '&pageNum=:pageNum&pageSize=:pageSize').get(parameters).$promise.then(function (data) {


                        for (var i = 0; i < data.data.length; i++) {
                            $scope.list.push(data.data[i]);
                        }
                        $scope.enabled = data.data.length > 0 && data.data.length === parameters.pageSize;
                        $scope.paginating = false;
                       
        });

    };



    $scope.loadList();


});
